clear 
set more off

* open data

use "Study_1_data.dta"

ssc install cibar
ssc install coefplot
ssc install estout, replace
ssc install orth_out
ssc install fre

label var news_corona "news exposure"

factor aot_1 aot_2 aot_3 aot_4 aot_5
alpha aot_1 aot_2 aot_3 aot_4 aot_5
gen aot_index=(aot_1+aot_2+aot_3+aot_4+aot_5)

factor consmentality_1 consmentality_2 consmentality_3 consmentality_4 consmentality_5
alpha consmentality_1 consmentality_2 consmentality_3 consmentality_4 consmentality_5
gen cm=(consmentality_1+consmentality_2+consmentality_3+consmentality_4+consmentality_5)

factor trust_congress trust_legal trust_pol trust_polit trust_party
gen poltrust=(trust_congress+trust_legal+trust_pol+trust_polit+trust_party)

// standardizing the variables for ease in interpretation [0,1]

	foreach var in poltrust aot_index cm intertrust trustCA trust_scien {
		qui sum `var'
		replace `var' = (`var' - `r(min)') / (`r(max)'-`r(min)')

	}

	foreach var in poltrust aot_index cm intertrust trustCA trust_scien {
tab `var' 
}

********************************************************************************
**************************** TABLE 1 *******************************************
********************************************************************************

//w/o covariates
reg change_misp i.treatment
estimates store m1
// w/ covariates
reg change_misp i.treatment gender age_cat edu ib(8).race ideology i.partisan_US trust_scient poltrust intertrust trustCA news_corona cm aot_index
estimates store m2
estout m1 m2, cells(b(star fmt(3)) se(par fmt(2)))  stats(r2)

sum change_misp


// wald test

reg change_misp i.treatment
test 2.treatment=3.treatment

/// to see what this effect mean in standardized terms, we standardize the change variable by the control condition´s mean and sd. 

sum change_misp if treatment==1
gen stanchange=(change_misp-.0510511)/.6308632  
reg stanchange i.treatment
estimates store m1
reg change_misp i.treatment gender age_cat edu ib(8).race ideology i.partisan_US trust_scient poltrust intertrust trustCA news_corona cm aot_index
estimates store m2
estout m1 m2, cells(b(star fmt(3)) se(par fmt(2)))  stats(r2)


********************************************************************************
**************************** ADDITIONAL TESTS***********************************
********************************************************************************

// Nyhan and Reifler Strategy

// rescaling the variables so that the greater numbers indicate more accurate beliefs.
fre mis_labmade
recode mis_labmade (1=5 "not accurate") (2=4 "probably not accurate") (3=3 "unsure") (4=2 "probably accurate") (5=1 "accurate"),gen(pre)
tab mis_labmade
tab pre


fre post_mis_labmade
recode post_mis_labmade (1=5 "not accurate") (2=4 "probably not accurate") (3=3 "unsure") (4=2 "probably accurate") (5=1 "accurate"),gen(post)
tab post_mis_labmade
tab post

reg post i.treatment pre
estimates store m1
// w/ covariates
reg post i.treatment pre gender age_cat edu ib(8).race ideology i.partisan_US trust_scient poltrust intertrust trustCA news_corona cm aot_index
estimates store m2
estout m1 m2, cells(b(star fmt(3)) se(par fmt(2)))  stats(r2)

// Manipulation Check Question

tab manipulation_check
tab treatment   // control, expert and minipublic

gen compliance=.
replace compliance=1 if manipulation_check==3&treatment==1   //control
replace compliance=0 if manipulation_check==3&treatment!=1   //control

replace compliance=1 if manipulation_check==1&treatment==2	//expert
replace compliance=0 if manipulation_check==1&treatment!=2	//expert

replace compliance=1 if manipulation_check==2&treatment==3	//mini-public
replace compliance=0 if manipulation_check==2&treatment!=3	//mini-public

replace compliance=0 if manipulation_check==4

tab compliance
tab treatment

by treatment, sort : tabulate compliance

// Table H1

by treatment, sort : tabulate manipulation_check

// Table H2

reg change_misp i.treatment if compliance==1
estimates store m1
// w/ covariates
reg change_misp i.treatment gender age_cat edu ib(8).race ideology i.partisan_US trust_scient poltrust intertrust trustCA news_corona cm aot_index if compliance==1
estimates store m2

estout m1 m2, cells(b(star fmt(3)) se(par fmt(2)))  stats(r2)

// Treating the "don´t know" as missing values, and deleting them list-wise and rerunning the analyses
fre mis_labmade
fre post_mis_labmade

recode mis_labmade (3=.) (4=3)(5=4),gen (m1)
tab mis_labmade
tab m1

recode post_mis_labmade (3=.) (4=3)(5=4),gen (m2)
fre post_mis_labmade
fre m2

gen changem=(m2-m1)
fre changem
recode changem (-3=3)(-2=2)(-1=1)(0=0)(1=-1)(2=-2)		//to make the positive coefficient to show correction

reg changem i.treatment
estimates store m1
// w/ covariates
reg changem i.treatment gender age_cat edu ib(8).race ideology i.partisan_US trust_scient poltrust intertrust trustCA news_corona cm aot_index
estimates store m2
estout m1 m2, cells(b(star fmt(3)) se(par fmt(2)))  stats(r2)

////
fre ideology
recode ideology (0 1 2 3 4=1 "left")(5=2 "middle")(6 7 8 9 10=3 "right"),gen(catide)
fre ideology
fre catide

	foreach var in gender age_cat edu_US race partisan_US catide {
tab `var' 
}

//// balance tests

orth_out gender age_cat edu_US race partisan_US catide, by(treatment) replace se compare test count

